package org.seefly.iprint.controller;

import org.seefly.iprint.entity.Helpinfo;
import org.seefly.iprint.service.HelpInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {
    private HelpInfoService service;

    public IndexController(HelpInfoService service) {
        this.service = service;
    }

    @RequestMapping("/index")
    public String shwoIndex(Model m) {
        //帮助信息
        List<Helpinfo> help = service.findNewHelpInfo(0,5);
        //广告
        List<Helpinfo> ads = service.findNewAdsInfo(0,5);
        //这俩东西只需要一个title 一个id就行了，多了浪费
        m.addAttribute("helpList", help);
        m.addAttribute("adsList", ads);
        return "index";
    }
    
    @RequestMapping("/getHelp")
    public String getInfo(String id,Model m) {
        Helpinfo info = service.getInfoById(id);
        m.addAttribute("info", info);
        return "front/InfoPage";
    }
}
